from django.db import models

from social.account.models import User
from social.feed.models import Post, Comment
from social.utils.models import BaseModel


class Review(BaseModel):
    OP_NEW_USER = "new_user"
    OP_NEW_POST = "new_post"
    OP_NEW_COMMENT = "new_comment"
    OP_UPDATE_NICKNAME = "update_nickname"

    status = models.IntegerField(default=0)
    user = models.ForeignKey(User, related_name='review', on_delete=models.CASCADE)
    post = models.ForeignKey(Post, related_name='review', on_delete=models.CASCADE)
    comment = models.ForeignKey(Comment, related_name='review', on_delete=models.CASCADE)
    op = models.CharField()

    def passed(self):
        self.status = 1
        self.save(update_fields=['status'])
